<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
      .d1 {
        width: 100px;
        height: 100px;
        background-color: red;
        float: left;
      }
      .d2 {
        width: 100px;
        height: 100px;
        background-color: blue;
        float: left;
      }
      /* box认为自己是个空元素，浮动元素不占用浏览器空间 */
      .box{
          background-color:green;
      }
      .clearfloat{
          clear: both;
          /* 清除上面最近的一个的浮动 */
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="d1">1</div>
      <div class="d2">2</div>
      <div class="clearfloat"></div>
    </div>
  </body>
</html>
